<template>
  <div class="mt20">
    <!-- 借款记录 -->
    <el-table :data="tableData" stripe style="width: 100%" size="small">
        <el-table-column align="center" prop="id" :label="$t('public.orderId')">
        </el-table-column>
        <el-table-column align="center" prop="createTime" :label="$t('public.CreateDate')">
        </el-table-column>
        <el-table-column align="center" prop="loanAmount" :label="$t('public.no24')">
        <template slot-scope="scope">
            <span>{{$store.getters.moneySplit(scope.row.loanAmount)}}</span>
        </template>
        </el-table-column>
        <el-table-column align="center" prop="productPeriod" :label="$t('public.no25')+'('+$t('public.no26')+')'">
        </el-table-column>
        <el-table-column align="center" prop="returnMoney" :label="$t('public.no27')" :formatter="moneyFormat">
        </el-table-column>
        <el-table-column align="center" prop="lastRefundTime" :label="$t('public.backMoneyDate')" width="86">
        </el-table-column>
        <el-table-column align="center" prop="isOverdue" :label="$t('public.isOverdue')">
        <template slot-scope="scope">
            <span>{{scope.row.overdueDays>0?$t('auditDetail.isOverdue.no1'):$t('auditDetail.isOverdue.no2')}}</span>
        </template>
        </el-table-column>
        <el-table-column align="center" prop="overdueDays" :label="$t('public.no28')">
        </el-table-column>
        <el-table-column align="center" prop="status" :label="$t('public.orderStatus')">
        <template slot-scope="scope">
            <span>{{$t($store.getters.rejectStatus(scope.row.status))}}</span>
        </template>
        </el-table-column>
        <el-table-column align="center" prop="operation" :label="$t('public.operation')">
        <template slot-scope="scope" v-if="true">
            <span @click="selLoan(scope.row.id)" class="table_opr">{{$t('public.no29')}}</span>
        </template>
        </el-table-column>
    </el-table>
  </div>
</template>
<script>
  export default {
    data() {
      return {
        userId: this.$route.query.userId, // 上个页面传进来的用户ID
        tableData: [] // 历史借款记录
      }
    },
    methods: {
      detail() { // 获取用户详细数据列表
        this.$axios.post(this.$action.user_userDetail+this.userId).then(res => {
            if (res.code == 200) {
                this.tableData = res.data.orderList;
            } else {
                this.$globalMsg.error(res.message);
            }
        });
      },
      selLoan(orderId) { // 借款查询
        this.$router.push({
          path: '/loandetail',
          query: {
            orderId,
            userId: this.userId
          }
        });
      },
      back() { // 页面无数据时，点击返回
        window.history.go(-1);
      },
      moneyFormat(row, column) {
        return row.loanAmount + row.overdueInterest
      },
    },
    mounted() {
      this.detail();
    }
  }
</script>